package com.qingcloud.df.executor.queue.publisher;

import com.qingcloud.df.executor.eventbus.MessageEvent;
import com.qingcloud.df.executor.eventbus.MessageEventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * akka发布者
 * @date 2022-01-20
 * @author yangfan
 */
@Component
public class AkkaPublisher implements ComponentPublisher {

    Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     * 事件总线
     */
    @Autowired
    private MessageEventBus messageEventBus;

    /**
     * 发送消息
     * @param topic 数据发送到的topic
     * @param data  要发送的数据
     */
    @Override
    public void send(String topic, String messageFrom, String data) {
        MessageEvent messageEvent  = new MessageEvent();
        messageEvent.setMessage(data);
        messageEvent.setTopic(topic);
        messageEvent.setMessageFrom(messageFrom);
        messageEventBus.publish(messageEvent);
    }
}
